package com.xiaofengstu.sms.service;

import com.google.protobuf.ProtocolStringList;
import com.xiaofengstu.news.proto.NewsServiceGrpc;
import com.xiaofengstu.sms.proto.SmsProto;
import com.xiaofengstu.sms.proto.SmsServiceGrpc;
import io.grpc.stub.StreamObserver;

/**
 * @Author FengZeng
 * @Date 2022-05-23 16:19
 * @Description TODO
 */
public class SmsService extends SmsServiceGrpc.SmsServiceImplBase {
  @Override
  public void sendSms(SmsProto.SmsRequest request, StreamObserver<SmsProto.SmsResponse> responseObserver) {
    String content = request.getContent();
    ProtocolStringList phoneNumberList = request.getPhoneNumberList();
    for (String phoneNumber : phoneNumberList) {
      SmsProto.SmsResponse response = SmsProto.SmsResponse.newBuilder().setResult(content + "，" + phoneNumber + "已发送").build();
      responseObserver.onNext(response);
    }
    responseObserver.onCompleted();
  }

}
